var str = document.URL.split("?")[1];
var obj = {};
var arr;
arr = str.split("=");
obj[arr[0]] = arr[1];
var no = obj.no;
var curtime = '';
var time = new Date();
var yea = time.getFullYear(); //获取完整的年份(4位,1970-???)
var mon = time.getMonth() + 1; //获取当前月份(0-11,0代表1月)
var day = time.getDate(); //获取当前日(1-31)
var hour = time.getHours(); //获取当前小时数(0-23)
var minute = time.getMinutes(); //获取当前分钟数(0-59)
var second = time.getSeconds(); //获取当前秒数(0-59)
curtime = yea + "-" + mon + "-" + day + " " + hour + ":" + minute + ":" + second;
var draftBox = new Vue({
    el: "#reply",
    data:
        {
            messages: '',
            timer:null,
        },
    methods: {
        send() {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/draftBox/getOne/' + no
            }).then(function (res) {
                draftBox.messages = res.data;
            }).catch(function (reason) {
                console.log(reason);
            })
        },
        UpdateTime(){
             time = new Date();
             yea = time.getFullYear(); //获取完整的年份(4位,1970-???)
             mon = time.getMonth() + 1; //获取当前月份(0-11,0代表1月)
             day = time.getDate(); //获取当前日(1-31)
             hour = time.getHours(); //获取当前小时数(0-23)
             minute = time.getMinutes(); //获取当前分钟数(0-59)
             second = time.getSeconds(); //获取当前秒数(0-59)
            curtime = yea + "-" + mon + "-" + day + " " + hour + ":" + minute + ":" + second;
        },
        updateDraft() {
            draftBox.$set(draftBox.messages, "updateTime",curtime)
            console.log(draftBox.messages)
            axios({
                method: 'POST',
                url: 'http://localhost:8099/draftBox/update',
                data: {
                    "informationId": draftBox.messages.informationId,
                    "receiver": draftBox.messages.receiver,
                    "updateTime": draftBox.messages.updateTime,
                    "onlinueMessage": draftBox.messages.onlinueMessage,
                }
            }).then(function (res) {
                alert(res.data)
                draftBox.send()
            }).catch(function (reason) {
                alert(res.data)
            })
        }
    },
    //页面加载完自动执行
    mounted() {
        this.send()
        this.timer=setInterval(this.UpdateTime,1000)
    }
});